const Service = require('egg').Service

class RegisterService extends Service {
    /* 查询邮箱的数量 */
    async find(email) {
        const user = await this.ctx.model.Users.count({
            where: { 'email': email }
        });
        return user
    }

    /* 注册用户 */
    async singUp(query) {
        const user = await this.ctx.model.Users.create({
            email: query.email,
            password: this.ctx.helper.password_to_crypto(query.password)
        })
        return user
    }
}

module.exports = RegisterService